home *** CD-ROM | disk | FTP | other *** search
Wrap
(* 2 3 4) => 24; (*) => 1 (+ 2 3 4) => 9; (+) => 0 (- 3) => -3; (- 2 3) => -1; (- 2 3 4) => -5 (/ 2) => 0.5; (/ 3 4) => 0.75; (/ 3 4 5) => 0.15 (> 5 4 3) => #t; (> 5 3 4) => #f (>= 5 4 3) => #t; (>= 5 3 4) => #f; (>= 5 3 3) => #t (= 2 2 2) => #t; (= 2 3 2) => #f (< 3 4 5) => #t; (< 4 3 5) => #f (<= 3 4 5) => #t; (<= 4 3 5) => #f; (<= 3 3 5) => #t (abs -2) => 2; (abs 3) => 3 (acos 0.5) =>1.047198; (acos #L0.75) => 0.7227342478134156108 (e::set-current-folder! "MyDisc:MyFolder:MySubFolder") => #t; (e::set-current-folder!) => (dialog box) => #t (append) => (); (append '(1 2 3) '(4 5 6)) => (1 2 3 4 5 6); (append '(1) () '(2)) => (1 2); (append '(1 2 3) '(4 5 6) 7) => (1 2 3 4 5 6 . 7) (apply + '(1 2 3 4 5)) => 15; (apply + 1 2 3 '(4 5)) => 15 (asin 0.5) => 0.5235988; (asin #L0.75) => 0.848062078981481008 (assoc 1 '((2 4) (1 5) (3 6) (1 2))) => (1 5); (assoc 4 '((2 4) (1 5))) => () (assq #f '((2 4) (#t 5) (3 6) (#f 2))) => (#f 2); (assq #f '((2 4) (1 5))) => () (assv #f '((2 4) (#t 5) (3 6) (#f 2))) => (#f 2); (assv 'foo '((2 4) (1 5))) => () (atan 0.5) => 0.4636476; (atan #L0.75) => 0.6435011087932843868; (atan -1000 0) => -1.570796 (begin (display (+ 2 2)) (newline) (+ 3 4)) writes "4" and a newline to the default output port, and returns 7. (boolean? #t) => #t; (boolean? 3) => #f (caaaar '((((x))))) => x (caaadr '(1 ((x)))) => x (caaar '(((x)))) => x (caadar '((1 (x)))) => x (caaddr '(1 2 (x))) => x (caadr '(1 (x))) => x (caar '((x))) => x (cadaar '(((1 x)))) =>x (cadadr '(1 (2 x))) => x (cadar '((1 x))) => x (caddar '((1 2 x))) => x (cadddr '(1 2 3 x)) => x (caddr '(1 2 x)) => x (cadr '(1 x)) (+ 2 (call-with-current-continuation (lambda (f) (f 3)))) => 5 (car '(x)) => x (cdaaar '((((1 . x))))) => x (cdaadr '(1 ((2 . x)))) => x (cdaar '(((1 . x)))) => x (cdadar '((1 (2 . x)))) => x (cdaddr '(1 2 (3 . x))) => x (cdadr '(1 (2 . x))) => x cdar '((2 . x))) => x (cddaar '(((1 2 . x)))) => x (cddadr '(1 (2 3 . x))) => x (cddar '((1 2 . x))) => x (cdddar '((1 2 3 . x))) => x (cddddr '(1 2 3 4 . x)) => x (cdddr '(1 2 3 . x)) => x (cddr '(1 2 . x)) => x (cdr '(1 . x)) => x (ceiling -1.5) => -1.; (ceiling -1.) => -1.; (ceiling 1.01) => 2. (char->integer #\a) => 97; (char->integer #\space) => 32 (char-alphabetic? #\a) => #t; (char-alphabetic? #\newline) => #f (char-ci<=? #\c #\B) => #f; (char-ci<=? #\c #\D) => #t; (char-ci<=? #\c #\C) => #t (char-ci<? #\c #\B) => #f; (char-ci<? #\c #\D) => #t; (char-ci<? #\c #\C) => #f (char-ci=? #\c #\B) => #f; (char-ci=? #\c #\D) => #f; (char-ci=? #\c #\C) => #t (char-ci>=? #\c #\B) => #t; (char-ci>=? #\c #\D) => #f; (char-ci>=? #\c #\C) => #t (char-ci>? #\c #\B) => #t; (char-ci>? #\c #\D) => #f; (char-ci>? #\c #\C) => #f (char-downcase #\A) => #\a; (char-downcase #\a) => #\a; (char-downcase #\@)=> #\@ (char-lower-case? #\a) => #t; (char-lower-case? #\A) => #f; (char-lower-case? #\3) => #f (char-numeric? #\a) => #f; (char-numeric? #\3) => #t (char-upcase #\A) => #\A; (char-upcase #\a) => #\A; (char-upcase #\@)=> #\@ (char-upper-case? #\a) => #f; (char-upper-case? #\A) => #t; (char-upper-case? #\3) => #f (char-whitespace? #\A) => #f; (char-whitespace? #\space) => #t (char<=? #\c #\a) => #f; (char<=? #\c #\d) => #t; (char<=? #\c #\c) => #t (char<? #\c #\a) => #f; (char<? #\c #\d) => #t; (char<? #\c #\c) => #f (char=? #\c #\a) => #f; (char=? #\c #\d) => #f; (char=? #\c #\c) => #t (char>=? #\c #\a) => #t; (char>=? #\c #\d) => #f; (char>=? #\c #\c) => #t (char>? #\c #\a) => #t; (char>? #\c #\d) => #f; (char>? #\c #\c) => #f (char? #\a) => #t; (char? 'foo) => #f (complex? 3) => #t; (complex? 'foo) => #f e::top-loop-code (cons 1 2) => (1 . 2); (cons 1 '(2 3)) => (1 2 3); (cons 1 ()) => (1); (cons () ()) => (()) (cos 0) => 1; (cos 3.14) => -0.9999987 c::define (display 3) … writes "3" on the default output port; (display 3 <an output port>) … writes "3" on the given output port (and #t (display 'Hello) #t 3) displays "hello" on the default output port and returns 3; (and #f (display 'hello)) displays nothing and returns #f. (case (+ 2 2) ((1 2) 'buckle-my-shoe) ((3 4) 'shut-the-door)) => shut-the-door; (case 5 ((1 2 3) 'finite) (else 'many)) => many; (case 5 ((1 2 3) 'finite)) => #t. (e::fixnum? 42) => #t; (e::fixnum? 42.5) => #f; (e::fixnum? 1'foo) => #f (e::flonum? 42) => #f; (e::fixnum? 42.5) => #t; (e::flonum? 1'foo) => #f (e::forced? (delay 3)) => #f; (e::forced? ((lambda (x) (force x) x) (delay 3))) => #t (e::promise? (delay 3)) => #t; (e::promise? 3) => #f else (eq? 2 2) => #t; (eq? 2 #L2.0) => #f; (eq? '(1 2 3) '(1 2 3)) => #f (equal? 2 2) => #t; (equal? 2 #L#E2.0) => #t; (equal? '(1 2 3) '(1 2 3)) => #t (eqv? 2 2) => #t; (eqv? 2 #L#E2.0) => #t; (eqv? '(1 2 3) '(1 2 3)) => #f (even? 2) => #t; (even? 1) => #f (exact? #e1) => #t; (exact? #i1) => #f (exp 3) => 20.08554 (expt 2 3) => 8.; (expt 3 2) => 9. (floor -1.5) => -2.; (floor -1.) => -1.; (floor 1.01) => 1. (for-each (lambda (x y) (display (sqrt (+ (* x x) (* y y))))(display " ")) '(3 5 8) '(4 12 15)) => 5. 13. 17. #t (force (delay 3)) => 3; (force (force (delay 3))) => 3 (if (> 3 2) 'first 'second) => first; (if (> 3 4) 'first 'second) => second; (if (> 3 4) 'first) => #f. (inexact? #e1) => #f; (inexact? #i1) => #t (char->integer #\a) => 97 (integer? 3.000) => #t; (integer? 'foo) => #f (lambda (n) (+ n 3)) returns a procedure which increments a number by three. (last-pair '(1)) => (1); (last-pair '(1 2 3)) => (3); (last-pair '(1 2 . 3)) => (2 . 3) (length '(1 2 3 4 5)) => 5 (define a 42) followed by (let* ((a 3) (b a)) b) => 3. (letrec ((odd (lambda (n) (if (= n 0) #f (even (- n 1))))) (even (lambda (n) (if (= n 0) #t (odd (- n 1)))))) (odd 3)) => #t. (list 1 2 (+ 1 2)) => (1 2 3); (list) => () (list->string '(#\A #\e #\c)) => "Aec" (list->vector '(#\A #\e #\c)) => #(#\A #\e #\c) (list-ref '(1 2 3) 0) => 1; (list-ref '(1 2 3) 1) => 2 (list-tail '(1 2 3) 0) => (1 2 3); (list-tail '(1 2 3) 2) => (3); (list-tail '(1 2 . 3) 2) => 3 (log 2) => 0.6931472 (make-string 3) => ; (make-string 3 #\x) => "xxx" (make-vector 3) => #(() () ()); (make-vector 3 #\x) => #(#\x #\x #\x) (map (lambda (x y) (sqrt (+ (* x x) (* y y)))) '(3 5 8) '(4 12 15)) => (5. 13. 17.) (max 1 3 2) => 3 (member '(1 2) '(2 #L#E2 (1 2))) => ((1 2)); (member #L#E2 '(2 #L#E2 (1 2))) => (2 2 (1 2)); (member 2 '(2 #L#E2 (1 2))) => (2 2 (1 2)) (memq '(1 2) '(2 #L#E2 (1 2))) => (); (memq #L#E2 '(2 #L#E2 (1 2))) => (); (memq 2 '(2 #L#E2 (1 2))) => (2 2 (1 2)) (memv '(1 2) '(2 #L#E2 (1 2))) => (); (memv #L#E2 '(2 #L#E2 (1 2))) => (2 2 (1 2)); (memv 2 '(2 #L#E2 (1 2))) => (2 2 (1 2)) (min 1 3 2) => 1 (modulo 13 4) => 1; (modulo 13 -4) => -3; (modulo -13 4) => 3; (modulo -13 -4) => -1 (negative? -1) => #t; (negative? 0) => #f; (negative? 1) => #f (not #f) => #t; (not 'foo) => #f (null? ()) => #t; (null? 'foo) => #f (number? 2.718) => #t; (number? 'foo) => #f (odd? 2) => #f; (odd? 1) => #t (cond (#t 'true) (else 'false)) => true; (cond (#f 'true) (else 'false)) => false; (cond (#f 'true)) => #t. (pair? (cons 'foo 'bar)) => #t; (pair? ()) => #f; (pair? 'foo) => #f (positive? -1) => #f; (positive? 0) => #f; (positive? 1) => #t (procedure? +) => #t; (procedure? (lambda( x ) x)) => #t; (procedure? 'foo) => #f `((+ 1 2) ,(+ 1 2)) => ((1 2) 3); ``((+ 1 2) ,(+ 1 2) ,,(+ 1 2)) => (quasiquote ((+ 1 2) (unquote (+ 1 2)) (unquote 3))). '(+ 2 2) => (+ 2 2). (quotient 13 4) => 3; (quotient 13 -4) => -3; (quotient -13 4) => -3; (quotient -13 -4) => 3 (rational? 3) => #t; (rational? 3.14) => #t; (rational? 'foo) => #f (real? 3) => #t; (real? 3.14) => #t; (real? 'foo) => #f (remainder 13 4) => 1; (remainder 13 -4) => 1; (remainder -13 4) => -1; (remainder -13 -4) => -1 (reverse '(1 2 3)) => (3 2 1) (round 0.5) => 0.; (round 1.5) => 2.; (round 0.4999) => 0.; (round 0.5001) => 1. (define a 1) followed by (set! a 3) makes a be 3. ((lambda (p) (set-car! p 'foo) p) (cons 1 2)) => (foo . 2) ((lambda (p) (set-cdr! p 'foo) p) (cons 1 2)) => (1 . foo) (sin 0) => 0.; (sin 3.14) => 1.592548e-3 (sqrt 0) => 0.; (sqrt 3.14) => 1.772004 (string->list "Abc") => (#A #b #c) (string->number "10" 'e 'x) => 16; (string->number "10" 'e 'd) => 10; (string->number "10" 'e 'o) => 8; (string->number "10" 'e 'b) => 2 (string->symbol "Foo") => Foo (string-append "abc" "def" "ghi") => "abcdefghi" (string-ci<=? "Aa" "ab") => #t; (string-ci<=? "Aa" "aa") => #t; (string-ci<=? "Ab" "aa") => #f (string-ci<? "Aa" "ab") => #t; (string-ci<? "Aa" "aa") => #f; (string-ci<? "Ab" "aa") => #f (string-ci=? "Aa" "ab") => #f; (string-ci=? "Aa" "aa") => #t; (string-ci=? "Ab" "aa") => #f (string-ci>=? "Aa" "ab") => #f; (string-ci>=? "Aa" "aa") => #t; (string-ci>=? "Ab" "aa") => #t (string-ci>? "Aa" "ab") => #f; (string-ci>? "Aa" "aa") => #f; (string-ci>? "Ab" "aa") => #t (string-copy "abc") => "abc" ((lambda (s) (string-fill! s #\a) s) "zzz") => "aaa" (string-length "abc") => 3; (string-length "") => 0 (string-ref "abc" 0) => #\a; (string-ref "abc" 2) => #\c ((lambda( s ) (string-set! s 1 #\X) s) (make-string 3)) => " X " (string<=? "aa" "ab") => #t; (string<=? "aa" "aa") => #t; (string<=? "ab" "aa") => #f (string<? "aa" "ab") => #t; (string<? "aa" "aa") => #f; (string<? "ab" "aa") => #f (string=? "aa" "ab") => #f; (string=? "aa" "aa") => #t; (string=? "ab" "aa") => #f (string>=? "aa" "ab") => #f; (string>=? "aa" "aa") => #t; (string>=? "ab" "aa") => #t (string>? "aa" "ab") => #f; (string>? "aa" "aa") => #f; (string>? "ab" "aa") => #t (string? "abc") => #t; (string? 'foo) => #f (substring "abcdef" 2 5) => "cde" (symbol->string 'foo) => "foo" (symbol? 'foo) => #t; (symbol? 3) => #f (tan 0) => 0.; (tan 1.57) => 1255.848 (truncate 0.5) => 0.; (truncate -1.5) => -1.; (truncate -0.9999) => 0.; (truncate 1.0001) => 1. `((+ 1 2) ,(+ 1 2)) => ((1 2) 3); ``((+ 1 2) ,(+ 1 2) ,,(+ 1 2)) => (quasiquote ((+ 1 2) (unquote (+ 1 2)) (unquote 3))). `(1 2 ,@(list (+ 2 1) (+ 2 2))) => (1 2 3 4). (vector 1 2 3) => #(1 2 3) (vector->list '#(1 2 3)) => (1 2 3) ((lambda( v ) (vector-fill! v 3) v) (make-vector 5)) => #(3 3 3 3 3) (vector-length '#(1 2 3)) => 3 (vector-ref '#(#\x #\y #\z) 1) => #\y ((lambda( v ) (vector-set! v 1 #\X) v) (make-vector 3)) => #(() #\X ()) (vector? '#()) => #t; (vector? '#(1 2 3)) => #t; (vector? 'foo) => #f (write 3) … writes "3" on the default output port; (write 3 <an output port>) … writes "3" on the given output port (zero? 0) => #t; (zero? 1) => #f (input-port? (open-input-file "foo")) => #t; (input-port? 'foo) => #f (output-port? (open-output-file "foo")) => #t; (output-port? 'foo) => #f (write-char #\a) … writes "a" to the default output port; (write-char #\a <an output port>) writes "a" to the given output port) (do ((x 1 (+ x 1))) ((= x 5) (display "Done") (newline)) (display x) (display " ")) => 1 2 3 4 Done ((lambda (x) (close-input-port x) (e::closed-port? x)) (open-input-file "foo")) => #t; (e::closed-port? 'foo) => #f (e::inf? 3) => #f; (e::inf? #t) => #f; (e::inf? 1.e10000) => #t (e::nan? 3) => #f; (e::nan? #t) => #f; (e::nan? 1.e10000) => #f; (e::nan? (- 1.e10000 1e10000)) => #t (number->string 3.1415926535 '(fix 3)) => "3.142"; (number->string 3.1415926535 '(sci 4 2)) => "31.42e-1"; and many, many more (gcd 12 28 60) => 4 (lcm 12 28 60) => 420 e::debug (e::cons-with-continuation '(+ 2 2)) => 4 • (e::bound-instance? 'asdfasdfghkkijl) => #f (probably); (e::bound-instance? '+) => #t (define a 42) makes a 42. • (e::address? (e::store 'foo)) => #t; (e::address? 'foo) => #f (e::load (e::store 'foo)) => foo (e::load (e::store 'foo)) => #<Pointer to memory location (hex) <… a number>> (e::macro foo (lambda (body) `(list ,@(cdr body)))) makes "foo" a macro that does approximately what "list" does. (or #t (display 'Hello) #t 3) displays nothing on the default output port and returns #t; (or #f (display 'hello)) displays "hello" on the default output port and returns #t. (e::macro? let) => #t; (e::macro? 'foo) => #f (e::expand-macro '(let ((x 3)) (+ x 4))) => ((lambda (x) (+ x 4)) 3) c::push c::apply (e::permanent? '+) => #t; (e::permanent? 'JustDrummingMyFingersOnTheKeyboard) => #f (probably) At top–level, (define a 3) folllowed by (c::symeval 'a) => 3 c::reset c::apply-end c::if c::if-aux-code c::noop c::s0-to-c c::stack-ref c::compiled-block (e::long-float? #L1) => #t; (e::long-float? 'foo) => #f (e::short-float? #S1) => #t; (e::short-float? 'foo) => #f – ± ±± ±±± ° °° °°° (define a 42) followed by (let ((a 3) (b a)) b) => 42. (let fact ((n 6)) (if (= n 0) 1 (* n (fact (- n 1))))) => 720. (e::bit-and #xC #xA) => 8 (e::bit-not #xC) => -13 (e::bit-or #xC #xA) => 14 (e::bit-xor #xC #xA) => 6 (e::bit-shift-left 3 4) => 48 (e::bit-shift-right-arithmetic 48 2) => 12; (e::bit-shift-right-arithmetic -1 2) => -1; (e::bit-shift-right-arithmetic -#x40000000 2) => -268435456 (e::bit-shift-right-logical 48 2) => 12; (e::bit-shift-right-logical -1 2) => 536870911; (e::bit-shift-right-logical -#x40000000 2) => 268435456 (e::file-exists? "SomeExistingFile") => #t; (e::file-exists? "NoSuchFile") => #f (define inc (e::compile-form (lambda (x) (+ x 1)))) causes "inc" to be bound to a compiled function that increments its argument (e::define-no-compile foo (lambda (x) x)) makes foo an uncompiled procedure which returns its argument. (e::proper-list? '(1 2 3)) => #t; (e::proper-list? '(1 2 . 3)) => #f; (e::proper-list? 1) => #f; (e::proper-list? '()) => #f (e::memvf '(1 2) '(2 #L#E2 (1 2))) => #f; (e::memvf #L#E2 '(2 #L#E2 (1 2))) => (2 2 (1 2)); (e::memvf 2 '(2 #L#E2 (1 2))) => (2 2 (1 2)) (e::not-null? '()) => #f; (e::not-null? 'foo) => #t